---
layout: m1x_soap
title: Enterprise Gift Message
---
				    
<h2><a name="MAPI-GiftMessage-Module%3AMageGiftMessage"></a>Module: Mage_GiftMessage</h2>

<p><font color="black">This module allows you to set a gift message for a quote or for a product in a quote.</font></p>


<h4><a name="MAPI-GiftMessage-Resource%3Agiftmessage"></a>Resource: giftmessage</h4>


<h5><a name="MAPI-GiftMessage-Methods%3A"></a>Methods:</h5>

<ul>
	<li><a href="giftmessage.setForQuote.html" title="giftmessage.setForQuote">giftmessage.setForQuote</a> &#45; Set a gift message for the shopping cart (quote)</li>
	<li><a href="giftmessage.setForQuoteItem.html" title="giftmessage.setForQuoteItem">giftmessage.setForQuoteItem</a> &#45; Set a gift message for an item in the shopping cart (quote)</li>
	<li><a href="giftmessage.setForQuoteProduct.html" title="giftmessage.setForQuoteProduct">giftmessage.setForQuoteProduct</a> &#45; Set a gift message for a product in the shopping cart (quote)</li>
</ul>




<h5><a name="MAPI-GiftMessage-Faults%3A"></a>Faults:</h5>


<table><tbody>
<tr>
<th> <font color="#333333">Fault Code</font> </th>
<th> <font color="#333333">Fault Message</font> </th>
</tr>
<tr>
<td> <font color="#333333">1001</font> </td>
<td> <font color="#333333">Can not make operation because store is not exists</font> </td>
</tr>
<tr>
<td> <font color="#333333">1002</font> </td>
<td> <font color="#333333">Can not make operation because quote is not exists</font> </td>
</tr>
<tr>
<td> <font color="#333333">1101</font> </td>
<td> <font color="#333333">Gift message data is not valid.</font> </td>
</tr>
<tr>
<td> <font color="#333333">1102</font> </td>
<td> <font color="#333333">Product's data is not valid.</font> </td>
</tr>
<tr>
<td> <font color="#333333">1103</font> </td>
<td> <font color="#333333">Quote item is not exists</font> </td>
</tr>
</tbody></table>


<h5><a name="MAPI-GiftMessage-Example%3A"></a>Example:</h5>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<div id="root">
		<pre class="theme: Default; brush: java; gutter: false">$proxy = new SoapClient('http://magentohost/api/soap/?wsdl');
$sessionId = $proxy-&gt;login('apiUser', 'apiKey');

// 创建一个报价, get quote identifier
$shoppingCartId = $proxy-&gt;call( $sessionId, 'cart.create', array( 'magento_store' ) );

// set gift message for quote
$giftMessage = array (
  'from' =&gt; 'test',
  'to' =&gt; 'test',
  'message' =&gt; 'test'
);

$giftMessageSetForQuoteResult = $proxy-&gt;call($sessionId,"giftmessage.setForQuote", array($shoppingCartId, $giftMessage, 'magento_store'));
print_r( $giftMessageSetForQuoteResult );


// add products into shopping cart
$arrProducts = array(
    array(
        'product_id' =&gt; '1',
        'qty' =&gt; 2
    ),
    array(
        'sku' =&gt; 'testSKU',
        'qty' =&gt; 4
    )
);
$resultCartProductAdd = $proxy-&gt;call($sessionId, 'cart_product.add', array($shoppingCartId, $arrProducts));

// set gift message for product
$giftMessage = array (
  'from' =&gt; 'test for Product',
  'to' =&gt; 'test for Product',
  'message' =&gt; 'test for Product'
);

/**
* Note:
* array for product should be the same as for cart_product.add
*/
$giftMessageSetForProductResult = $proxy-&gt;call(
  $sessionId,
  "giftmessage.setForQuoteProduct",
  array(
    $shoppingCartId,
    array(
        array(
            'product' =&gt; $arrProducts[0],
            'giftmessage' =&gt; $giftMessage,
        ),
        array(
            'product' =&gt; $arrProducts[1],
            'giftmessage' =&gt; $giftMessage,
        )
    ),
    'magento_store'
    )
);

print_r( $giftMessageSetForProductResult );</pre>
		</div>
</div></div>

				    
Create the Magento文件系统所有者                   			    
